<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input id="n1" type="text">
    <select name="" id="sel">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
    </select>
    <input type="text" id="n2">
    <button>=</button>
    <input id="res" type="text" onclick="operation()">
    <script>
        /* - 编写一个函数，计算任意数字的和、差、积、商
        要求：使用传参的形式 */
        // operation 运算

        function operation() {
            var n1 = document.getElementById('n1').value - 0            //获取n1的值
            var s = document.getElementById('sel').value                //获取sel
            var n2 = document.getElementById('n2').value - 0            //获取n1的值
            var r;                                                      //结果
            switch (s) {
                case '+': r = n1 + n2;
                    break;
                case '-': r = n1 - n2;
                    break;
                case '*': r = n1 * n2;
                    break;
                case '/': r = n1 / n2;
            }
            document.getElementById('res').value = r;
        }
        operation();

        // - 编写一个函数，计算三个数字的大小，按从小到大顺序输出
        function isShun() {
            var t = 0;
            for (var i = 0; i < arguments.length; i++) {
                for (var j = i; j < arguments.length; j++) {
                    if(arguments[i] < arguments[j]){
                        t = arguments[i];
                        arguments[i] = arguments[j];
                        arguments[j] = t;
                    }
                }
            }
            return arguments;
        }
        var s = isShun(5,10,12);
        console.log(s);
        
    </script>
</body>

</html>